use sea_orm_migration::prelude::*;

use crate::m20220521_223848_view_book_pub_status::{apply_sql_migration, undo_sql_migration};

pub struct Migration;

impl MigrationName for Migration {
    fn name(&self) -> &str {
        "m20220521_225755_view_users"
    }
}

#[async_trait::async_trait]
impl MigrationTrait for Migration {
    async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        apply_sql_migration("view_admin", manager).await?;
        apply_sql_migration("view_custom", manager).await?;
        Ok(())
    }

    async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        undo_sql_migration("view_custom", manager).await?;
        undo_sql_migration("view_admin", manager).await?;
        Ok(())
    }
}
